<?php include ("main.php")?>
<?php $db = new mysqli('localhost', 'root', '', 'frcc_test'); 

if (mysqli_connect_errno()) 
{    die ('Could not open a mysql connection: '.mysqli_connect_error().'('.mysqli_connect_errno().')');
}

$db->query("SET NAMES 'utf8'");
$sql = 'SELECT id, uid, pwd, cname, name, phone FROM directory';
$result = $db->query($sql);
if (!$result) 
{    die ('Something is wrong with the query: '.$db->error);
}
echo 'The result set got '.$result->num_rows." rows<br />\n";

while ($row = $result->fetch_assoc()) 
{
	// NULL is equivalent to false    
	// $row is now the array with the values.    
	
	echo 'The person <a href="edit.php?id='.$row['id'] . '">'.$row['id']. '</a> '  .$row['cname'].' '. $row['uid'] . ' ' .$row['name']. ' p:' . $row['pwd'] . ' ' . $row['phone'] . "<br />\n";
}

unset($result); 

// you can delete the variable with unset() as it isn't needed anymore.

?>

</body>
</html>
